package net.wanho.vo;

import com.alibaba.fastjson.annotation.JSONPOJOBuilder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

/**
 * Author：汤小洋
 * Date：2025-01-12 15:27
 * Description：<描述>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private Integer code;
    private Boolean success;
    private String message;
    private Object data;

    public static R ok(Object data) {
        return new R(HttpStatus.OK.value(), true, "操作成功", data);
    }

    public static R ok() {
        return new R(HttpStatus.OK.value(), true, "操作成功", null);
    }

    public static R ok(String message, Object data) {
        return new R(HttpStatus.OK.value(), true, message, data);
    }

    public static R error(String message) {
        return new R(HttpStatus.INTERNAL_SERVER_ERROR.value(), false, message, null);
    }

    public static R error(Integer code, String message) {
        return new R(code, false, message, null);
    }

}
